<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/sys/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%@ include file="/WEB-INF/adminui/include/css.jsp" %>
<title>农作物管理</title>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
	<div class="row">
		<div class="col-sm-2">
			<div class="ibox ibox-body">
				<div class="ibox-title">
					<h5>农作物分类</h5>
				</div>
				<div class="ibox-content">
					<div id="jstree"></div>
				</div>
			</div>
		</div>
		<div class="col-sm-9">
			<div class="ibox">
				<div class="ibox-body">
					<div class="fixed-table-toolbar">
						<div id="toolbar_ROOT" class="columns pull-left uilist-toolbar uilist-toolbar-ROOT">
							<qx:perm code="crop_ZZ_DL_ADD">
							<button type="button" class="btn btn-primary" onclick="addDl()">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>添加大类
							</button>
							</qx:perm>
							<qx:perm code="crop_ZZ_DL_DEL">
							<button type="button" class="btn btn-danger multi" onclick="delDl()">
								<i class="fa fa-trash hidden" aria-hidden="true"></i>删除大类
							</button>
							</qx:perm>
						</div>
						<div id="toolbar_TYPE" class="columns pull-left uilist-toolbar uilist-toolbar-TYPE">
							<qx:perm code="crop_ZZ_XL_ADD">
							<button type="button" class="btn btn-primary" onclick="addXl()">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>添加小类
							</button>
							</qx:perm>
							<qx:perm code="crop_ZZ_XL_DEL">
							<button type="button" class="btn btn-danger multi" onclick="delXl()">
								<i class="fa fa-trash hidden" aria-hidden="true"></i>删除小类
							</button>
							</qx:perm>
						</div>
						<div id="toolbar_CROP" class="columns pull-left uilist-toolbar uilist-toolbar-CROP">
							<qx:perm code="crop_ZZ_HJ_ADD">
							<button type="button" class="btn btn-primary" onclick="addHj()">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>添加环节
							</button>
							</qx:perm>
							<qx:perm code="crop_ZZ_HJ_DEL">
							<button type="button" class="btn btn-danger multi" onclick="delHj()">
								<i class="fa fa-trash hidden" aria-hidden="true"></i>删除环节
							</button>
							</qx:perm>
						</div>
					</div>
					<table id="dataTable" data-mobile-responsive="true">
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<%@ include file="/WEB-INF/adminui/include/script.jsp" %>
<script type="text/javascript">
$(function(){
	UiList.render({
		treeUrl: '${path}/crops/cropsjstree.json',
		multiTableSupport: true,
		multiTableConfig:{
			ROOT:{
				url: "${path}/crops/listDldata.json",
				idfield: 'typeid',
				toolbar: 'toolbar_ROOT',
				columns: [
					{checkbox : true},
					{field : 'typeCode', title : '名称'},
					{field : 'typeName', title : '编码'},
					{field : 'remark', title : '描述'},
					{field : 'typeid', title : '操作', align : 'center', formatter : function(value, row, index) {
						var s = '';
						<qx:perm code="crop_ZZ_DL_EDIT">
						s += '<a class="btn btn-primary btn-sm" href="javascript:;" title="修改" onclick="editDl(\''+value+'\')">修改</a>';
						</qx:perm>
						return s;
					}}
				]
			},
			TYPE:{
				url: "${path}/crops/listdata.json",
				idfield: 'cropid',
				toolbar: 'toolbar_TYPE',
				columns: [
					{checkbox : true},
					{field : 'cropName', title : '作物名称'},
					{field : 'cropCode', title : '作物编码'},
					{field : 'units', title : '单位'},
					{field : 'cropid', title : '操作', align : 'center', formatter : function(value, row, index) {
						var s = '';
						<qx:perm code="crop_ZZ_XL_EDIT">
						s += '<a class="btn btn-primary btn-sm" href="javascript:;" title="修改" onclick="editXl(\''+value+'\')">修改</a>';
						</qx:perm>
						return s;
					}}
				]
			},
			CROP:{
				url: "${path}/prolink/listdata.json",
				idfield: 'linkid',
				toolbar: 'toolbar_CROP',
				columns: [
					{checkbox : true},
					{field : 'linkName', title : '环节名称'},
					{field : 'linkType', title : '环节分类',formatter : function(value, row, index) {
						switch(''+value){
						case '0': return '基本环节';
						case '1': return '播种环节';
						case '2': return '施肥环节';
						case '3': return '植保环节';
						case '4': return '收获环节';
						
						}
						return ''+value;
					}},
					{field : 'linkCode', title : '环节编码'},
					{field : 'linkid', title : '操作', align : 'center', formatter : function(value, row, index) {
						var s = '';
						<qx:perm code="crop_ZZ_HJ_EDIT">
						s += '<a class="btn btn-primary btn-sm" href="javascript:;" title="修改" onclick="editHj(\''+value+'\')">修改</a>';
						</qx:perm>
						return s;
					}}
				]
			}
		}
	});
	
});

function addDl(){
	UiList.open('${path}/crops/addDl.do', '添加种植大类信息', {refresh:true});
}
function delDl(){
	UiList.dialog('${path}/crops/deleteDl.json', '您确定要删除选中的种植大类信息吗？', '删除种植大类信息成功.', {refresh:true});
}
function editDl(id){
	UiList.open('${path}/crops/editDl.do?typeid='+id, '修改种植大类信息', {refresh:true});
}

function addXl(){
	UiList.open('${path}/crops/add.do', '添加种植小类', {refresh:true});
}
function delXl(){
	UiList.dialog('${path}/crops/delete.json', '您确定要删除选中的种植小类吗？', '删除种植小类成功.', {refresh:true});
}
function editXl(id){
	UiList.open('${path}/crops/edit.do?cropid='+id, '修改种植小类', {refresh:true});
}

function addHj(){
	UiList.open('${path}/prolink/add.do', '添加环节信息', {refresh:true});
}
function delHj(){
	UiList.dialog('${path}/prolink/delete.json', '您确定要删除选中的环节信息吗？', '删除作物信息成功.', {refresh:true});
}
function editHj(id){
	UiList.open('${path}/prolink/edit.do?linkid='+id, '修改环节信息', {refresh:true});
}
</script>
</body>
</html>